package cn.edu.seig.textbook.config;

import cn.edu.seig.textbook.task.ReminderJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author lenovo
 */
@Configuration
public class QuartzConfig {
    @Bean
    public JobDetail jobDetail() {
        return JobBuilder.newJob(ReminderJob.class).withIdentity("reminderJob").storeDurably().build();

    }
    @Bean
    public Trigger trigger(JobDetail jobDetail) {
        CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule("0/30 * * 30 12 ?");
        Trigger trigger= TriggerBuilder.newTrigger().withIdentity("reminderTrigger").forJob(jobDetail()).withSchedule(scheduleBuilder).build();
        return trigger;
    }
}
